# Contributor: alpine-mips-patches <info@mobile-stream.com>
# Maintainer: alpine-mips-patches <info@mobile-stream.com>
pkgname=compcert
_pkgname=CompCert
pkgver=3.5
pkgrel=0
pkgdesc="The verified C compiler"
url="https://compcert.inria.fr"
arch="armhf armv7 riscv64 x86_64"
license="custom"
depends="gcc"
makedepends="ocaml ocaml-compiler-libs ocaml-menhir-dev coq"
subpackages="$pkgname-doc"
source="https://compcert.inria.fr/release/$pkgname-$pkgver.tgz
	fix-cprepro-options.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	cd "$builddir"

	local _target
	case "$CARCH" in
	armhf) _target="armv6-hardfloat";;
	armv7) _target="armv7a-hardfloat";;
	riscv64) _target="rv64-linux";;
	ppc|ppc64) _target="$CARCH-linux";;	# yes, big-endian only
	x86) _target="x86_32-linux";;		# assumes SSE2
	x86_64) _target="x86_64-linux";;
	esac

	./configure \
		-prefix /usr \
		$_target
	make
}

check() {
	cd "$builddir"
	unset CPPFLAGS
	make -C test all
	make -C test test
}

package() {
	cd "$builddir"
	make install \
		PREFIX="$pkgdir/usr" \
		SHAREDIR="$pkgdir/usr/share/compcert"
}

sha512sums="9c72aac0c72e7b9db68e34f469dbd02e4c7d88c54d8b001891e05ae5c5a1e4323be25bab7d53334943fec26e2b64d3a21972d38a589fc79cc8d4bf0185cec50b  compcert-3.5.tgz
5bdafee9e97c81505853ee2c5263067f98fce937af9c5eac79f51b0998ab9694811761ab5a131cac27109b3e8c84d9cbe293f11b66afce6e4910d452ce648de8  fix-cprepro-options.patch"
